package pers.hmedical.hospital.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import pers.hmedical.base.util.R;
import pers.hmedical.hospital.bean.VO.HospitalSetQueryVO;
import pers.hmedical.hospital.domain.HosInfo;
import pers.hmedical.hospital.service.HosInfoService;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author wei-xhh
 * @date 2021-06-12
 */
@Api(tags = "医院设置管理")
@RestController
@RequestMapping("/admin/hosp/hospitalSet")
public class HosInfoController {

    @Resource
    HosInfoService hosInfoService;

    /**
     * 查询医院设置表所有信息
     *
     * @return 结果
     */
    @ApiOperation(value = "获取所有医院设置", notes = "", httpMethod = "GET")
    @GetMapping("/findAll")
    public R findAllHospitalSet() {
        return hosInfoService.findAll();
    }

    /**
     * 删除医院设置
     *
     * @return 结果
     */
    @ApiOperation(value = "逻辑删除医院设置", notes = "", httpMethod = "DELETE")
    @DeleteMapping("{id}")
    public R removeHospSet(@PathVariable Long id) {
        return hosInfoService.removeHospSet(id);
    }

    /**
     * 条件查询带分页
     *
     * @return
     */
    @ApiOperation(value = "条件查询带分页", notes = "条件查询医院设置管理带分页", httpMethod = "POST")
    @ApiImplicitParams({
            @ApiImplicitParam()
    })
    @PostMapping("/findPageHospSet/{current}/{limit}")
    public R findPageHospSet(@PathVariable long current,
                             @PathVariable long limit,
                             @RequestBody(required = false) HospitalSetQueryVO hospitalSetQueryVO) {
        return hosInfoService.findPageHospSet(current, limit, hospitalSetQueryVO);
    }

    /**
     * 保存
     *
     * @param hosInfo
     * @return
     */
    @ApiOperation(value = "保存", notes = "医院设置管理保存", httpMethod = "POST")
    @PostMapping("/saveHospitalSet")
    public R saveHospitalSet(@RequestBody HosInfo hosInfo) {
        return hosInfoService.saveHospitalSet(hosInfo);
    }

    /**
     * 获取一条
     *
     * @param id
     * @return
     */
    @ApiOperation(value = "获取一条", notes = "获取一条医院设置管理", httpMethod = "GET")
    @GetMapping("/getHospSet/{id}")
    public R getHospSet(@PathVariable long id) {
        return hosInfoService.getHospSet(id);
    }

    /**
     * 修改医院设置
     *
     * @param hosInfo
     * @return
     */
    @ApiOperation(value = "修改医院设置", notes = "修改医院设置管理", httpMethod = "POST")
    @PostMapping("/updateHospitalSet")
    public R updateHospitalSet(@RequestBody HosInfo hosInfo) {
        return hosInfoService.updateHospitalSet(hosInfo);
    }

    /**
     * 批量删除医院设置
     *
     * @param idList
     * @return
     */
    @ApiOperation(value = "批量删除医院设置", notes = "批量删除医院设置管理", httpMethod = "DELETE")
    @PostMapping("/batchRemove")
    public R batchRemove(@RequestBody List<Long> idList) {
        return hosInfoService.batchRemove(idList);
    }

    @GetMapping("/hello")
    public R hello() {
        return R.ok();
    }

}
